home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / ansicvid.zip / ANSICVID.C
Text File  |  1989-07-14  |  3KB  |  141 lines

  1. /* ansivid.c */
  2.  
  3. /* ANSI control routines for MS-DOS video */
  4. /* In Public Domain */
  5. /* for use with Microsoft C ver. 3.0 compiler */
  6.  
  7. /*****************************************************************/
  8.  
  9. /*----------- NOTE: YOU MUST INVOKE 'DEVICE=ANSI.SYS' AT DOS LEVEL AND---*/
  10. /*------------------YOU MUST HAVE THE FILE 'ANSI.SYS' LOCATED------------*/
  11. /* ----------------   IN YOUR ROOT DIRECTORY ----------------------------*/
  12.  
  13. /*************************************************************************/
  14.  
  15. /* Sept 10 1986 */
  16. /* L. Stephen Bell, c/o Lunar & Planetary Lab, Univ. of Az,Tucson Arizona */
  17. /*             85721                                602-886-0421 */
  18.  
  19. /* Please give me a call or send your new ideas for */
  20. /* incorporation into the next revision of this code*/
  21.  
  22.  
  23. #include <conio.h> /* HSR PACKAGE */
  24.  
  25.  
  26. /* test routine for the functions to follow: delete this code or comment it */
  27. /* out after you have seen how everything works */
  28.  
  29.  
  30.  
  31. main()
  32. {
  33. cls();
  34.  
  35. printf("This is normal text printed via the printf function.\n");
  36. delay(32000);
  37.  
  38. tputs(12,12,"This is printed at 12,12 location.\n");
  39. delay(45000);
  40.  
  41. bold();
  42. tputs(14,14,"This is bold.\n");
  43. delay(45000);
  44.  
  45. reverse();
  46. tputs(1,20,"Reverse");
  47. delay(45000);
  48.  
  49. normal();
  50. blink();
  51. tputs(2,19,"Blinking");
  52. delay(45000);
  53.  
  54. blink_rev();
  55. tputs(4,12,"Blinking AND reverse!");
  56. delay(45000);
  57.  
  58. normal();
  59. tputs(6,15,"This line will be partly erased to its end . . . . ");
  60. delay(145000);
  61.  
  62. locate(6,25);
  63. clr_eol();
  64. delay(45000);
  65.  
  66. normal();    
  67. }
  68. /* end of commented out main routine */
  69.  
  70. /*------------------ end of test routine---------------------------- */
  71.  
  72.  
  73.  
  74.  
  75. /*----------------ANSI Screen Driving Function Library:----------------*/
  76. cls()
  77.   {
  78.   cprintf("\033[2J");    /* clear, home */
  79.   }
  80.   
  81. bold()
  82.   {
  83.   cprintf("\033[1m");    /* set for bold-printed text to follow */
  84.   }
  85.   
  86. normal()
  87.   {
  88.   cprintf("\033[0m");    /* set normal (non-bold) text to follow */
  89.   }
  90.   
  91. reverse()
  92.   {
  93.   cprintf("\033[7m");    /* set for reverse video */
  94.   }
  95.   
  96. blink()
  97.   {
  98.   cprintf("\033[5m");    /* set for blinking attribute */
  99.   }
  100.   
  101. blink_rev()
  102.   {
  103.   cprintf("\033[5;7m");    /* set for blinking AND reverse video */
  104.   }
  105.   
  106. clr_eol()
  107.   {
  108.   cprintf("\033[K");    /* clear from cursor to end of line */
  109.   }
  110.   
  111. locate(row,col)            /* absolute cursor positioning */
  112. short row,col;
  113.   {
  114.   printf("\033[%d;%df",row,col);
  115.   }
  116.  
  117.  
  118. tputs(row,col,text)    /* puts a text string to row,col position on screen*/
  119. short row,col;
  120. char *text;
  121. {
  122.   locate(row,col);
  123.   printf("%s",text);
  124. }
  125.  
  126. delay(time)        /* variable delay routine for pauses */
  127. unsigned time;
  128. {
  129. int j,k;
  130.  
  131. for( j = 0; j <= time; j++)
  132.     {
  133.     k  = k /2;
  134.     k  = k*2;
  135.     }
  136. }
  137.  
  138.   
  139. /* ------------------------ END ansivid.c ----------------------------*/                                                                                            
  140.  
  141.